import {reactive} from "vue";
import http from "../http";
const healthDetail = reactive({
    health_category_List: [],    // 大众健康-健康分类列表
    health_disease_List: [],     // 大众健康-疾病分类列表
    current_category: 0,  // 当前选中的健康分类，0表示所有健康分类
    current_disease: 0,  // 当前选中的疾病分类，0表示所有疾病分类
    health_name: "",
    type_id: 0,
    health_info_list: [],
    count: 0,
    page: 1,
    get_health_category_name(){
        // 获取大众健康-健康分类信息
        return http.get(`/health/healthCategory/${this.current_category}/`).then(response=>{
            console.log(response.data.name)
            this.health_name = response.data.name;
        })
    },
    get_health_disease () {
        // 获取大众健康-疾病分类信息
        return http.get(`/health/healthDisease/${this.current_category}/`,).then(response=>{
            console.log('大众健康-疾病分类信息请求成功..........');
            console.log(response);
            this.health_disease_List = response.data;
        }).catch((err) => {
            console.log('大众健康-疾病分类信息请求失败------');
            console.log(err);
        });
    },
    get_life_category_name(){
        // 获取生活手册-生活分类信息
        return http.get(`/health/lifeCategory/${this.current_category}/`).then(response=>{
            console.log(response.data.name)
            this.health_name = response.data.name;
        })
    },
    get_life_disease () {
        // 获取生活手册-生活技巧信息
        return http.get(`/health/lifeDisease/${this.current_category}/`,).then(response=>{
            console.log('大众健康-疾病分类信息请求成功..........');
            console.log(response);
            this.health_disease_List = response.data;
        }).catch((err) => {
            console.log('大众健康-疾病分类信息请求失败------');
            console.log(err);
        });
    },
    get_health_info(){
        // 获取疾病分类信息
        return http.get(`/health/healthInfo/${this.current_disease}/?page=${this.page}`,).then(response=>{
            console.log('疾病分类信息请求成功..........');
            console.log(response);
            this.health_info_list = response.data.results;
            this.count = response.data.count;
            console.log(this.health_info_list.length)
        }).catch((err) => {
            console.log('疾病分类信息请求失败------');
            console.log(err);
        });
    },
    get_life_info(){
        // 获取生活手册-生活技巧信息
        return http.get(`/health/lifeInfo/${this.current_disease}/?page=${this.page}`,).then(response=>{
            console.log('生活技巧信息请求成功..........');
            console.log(response);
            this.health_info_list = response.data.results;
            this.count = response.data.count;
            console.log(this.health_info_list.length)
        }).catch((err) => {
            console.log('生活技巧信息请求失败------');
            console.log(err);
        });
    },


})

export default healthDetail;